#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project ：back 
@File    ：identity_token.py
@IDE     ：PyCharm 
@Author  ：七分是你
@Date    ：2024/6/29 下午7:28 
@explain : 
"""
import time

from app import dao
from app.utils.str_util import StringUtil


class IdentityToken:
    @classmethod
    def makeToken(cls, uid, token, expire=86400):
        print("makeTokenuid========", uid)
        mdtoken = StringUtil.GenerateMd5(token)
        identity_token_data = dao.IdentityTokenQueryDao.find(**{'mdtoken': mdtoken})
        if identity_token_data:
            dao.IdentityTokenOperateDao.delete_token(identity_token_data.mdtoken)
        dao.IdentityTokenOperateDao.save(
            {'mdtoken': mdtoken, 'updatetime': int(time.time()), 'expire': expire, 'uid': uid})
